<template>
    <div class="wai">
        <h1 class="title">{{ msg }}</h1>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in goods_list" :key="item.goods_id" >
                <div class="mui-navigate-right" @click="change_goods(item.goods_id,item)">
                    <div class="mui-media-body">商品名称：{{ item.name }}<p></p>剩余数量：{{ item.count }}</div>
                </div>
            </li>
        </ul>
    </div>
</template>
<script>
export default {
    data() {
        return {
            msg: '我的商品',
            goods_list: []
        }
    },
    methods: {
        get_goods_list() {
            this.$http.post('my_goods.php', { 'session_id': this.$auth.getAuthorization() },
                {
                    headers: {
                        'Content-Type': 'application/json' // 设置请求头
                    }
                }).then(response => {
                    if (response.data.status === 1) {
                        // alert('成功');
                        console.log('成功');
                    } else {
                        // alert('失败');
                        console.log('失败');
                    }
                    this.goods_list = response.data.data;
                })
                .catch(error => {
                    console.error(error);
                });
        },
        change_goods(goods_id,item) {
            this.$router.push({ name: 'my_goods_info', params: { 
                id:goods_id,
                news:item
            
            } });
        }
    },
    created() {
        this.get_goods_list();
    }
};
</script>
  
  <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.wai {
    border: 1px solid red;
    margin-top: -1%;
    padding-left: 5%;
    padding-right: 3%;
    .title{
        font-size: 50px;
        margin-top: 2%;
        // margin-left: 5%;
    }
    .mui-table-view {
        max-height: 835px;
        overflow-y: auto;
      
        .mui-table-view-cell {
            height: 55px;
        }
    }

}
</style>
                                                                          